package com.away.fuckingworld.exception;

import com.away.fuckingworld.entity.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;

/**
 * 全局异常处理类
 */
@Slf4j
@RestControllerAdvice(annotations = Controller.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public class WebExceptionResolver  {
    @ExceptionHandler(Throwable.class)
    public Object handle(Throwable ex){
        StringBuilder errorMsg = new StringBuilder();

        return ResultVO.error(HttpStatus.INTERNAL_SERVER_ERROR.value(),errorMsg.toString());
    }

}
